//
//  ContentView.swift
//  Scaner
//
//  Created by liyahao on 2025/4/8.
//

import SwiftUI

struct ContentView: View {
    @State var isPresent = false
    @State var isRecord = false
    @StateObject var vModel = ScanDocVModel()
    
    var body: some View {
        ZStack {
            Color.black.ignoresSafeArea(.all)
            VStack(spacing: 20) {
                Button {
                    isPresent.toggle()
                } label: {
                    Text("文档拍照")
                        .font(.system(size: 20))
                        .foregroundStyle(.white)
                        .padding(.vertical, 10)
                        .padding(.horizontal, 20)
                        .background(.red)
                        .clipShape(RoundedRectangle(cornerRadius: 20))
                }
                
                Button {
                    isRecord.toggle()
                } label: {
                    Text("录音")
                        .font(.system(size: 20))
                        .foregroundStyle(.white)
                        .padding(.vertical, 10)
                        .padding(.horizontal, 20)
                        .background(.red)
                        .clipShape(RoundedRectangle(cornerRadius: 20))
                }
            }
        }
        .sheet(isPresented: $isRecord, content: {
            RecordingView()
        })
        .fullScreenCover(isPresented: $isPresent) {
            ScanDocumentView(cancelAction: vModel.cancelOCR, resultAction: vModel.resultAction)
        }
    }
}

#Preview {
    ContentView()
}
